package com.sharp.portal.dao.repository;

import com.sharp.kernel.mybatis.repository.BaseMysqlRepository;
import com.sharp.portal.dao.entity.CoPortalCondition;
import com.sharp.portal.dao.mapper.CoPortalConditionDao;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * Title: CoPortalCondtionRepository
 * Description: Copyright: Copyright (c) 2022 Company: Sharp Ltd.
 *
 * @author Sharp
 * @date 2022/10/08 10:33
 */
@Service
public class CoPortalConditionService extends BaseMysqlRepository<CoPortalCondition, CoPortalConditionDao> {

    public List<CoPortalCondition> getCondition(String path) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("path", path);
        return super.select(example);
    }

    public List<CoPortalCondition> getCondition(String path, String status) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("path", path);
        criteria.andEqualTo("status", status);
        return super.select(example);
    }

    public void deleteByPath(String path) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("path", path);
        super.delete(example);
    }
}
